using System.Collections.Generic;
using JlPay.Sdk.Models;

namespace JlPay.Sdk.Models.Openmerch.Device
{
    /// <summary>
    /// 终端查询请求
    /// @author liaochangyi
    /// @since 2025-01-25
    /// </summary>
    public class DeviceQueryRequest : OrgBaseRequest
    {
        /// <summary>
        /// API URL
        /// </summary>
        public const string API_URL = "/open/merch/access/device/query";

        /// <summary>
        /// 商户号，终端号、机身号不传查该商户下所有的终端信息
        /// </summary>
        public string? MerchNo { get; set; }

        /// <summary>
        /// 终端编号，填入终端号时查询该终端号的终端信息，终端号必须为该商户号下的终端
        /// </summary>
        public string? TermNo { get; set; }

        /// <summary>
        /// 设备硬件序列号（SN），填入机身号时查询该设备的终端信息，机身号必须该商户号下加机绑定的设备对应的机身号
        /// </summary>
        public string? DeviceNo { get; set; }

        /// <summary>
        /// 转换为字典
        /// </summary>
        /// <returns>字典数据</returns>
        public Dictionary<string, object> ToDictionary()
        {
            var data = new Dictionary<string, object>();

            // 添加基础字段
            if (!string.IsNullOrEmpty(OrgNo))
            {
                data["org_no"] = OrgNo;
            }
            if (!string.IsNullOrEmpty(base.MerchNo))
            {
                data["merch_no"] = base.MerchNo;
            }

            // 添加业务字段
            if (!string.IsNullOrEmpty(MerchNo))
            {
                data["merch_no"] = MerchNo;
            }
            if (!string.IsNullOrEmpty(TermNo))
            {
                data["term_no"] = TermNo;
            }
            if (!string.IsNullOrEmpty(DeviceNo))
            {
                data["device_no"] = DeviceNo;
            }

            return data;
        }
    }
} 